< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03060100.xhp

(section: and) (bookmark: bm_id3146117)
AND operator (logical)

And 論理演算子

AND Operator [Runtime]
AND 演算子 [実行時](hd_id3146117.1)

Logically combines two expressions.
2 つの表式間の論理積演算を行います。(par_id3143268.2)

(/section: and)

Syntax:
構文:(hd_id3147574.3)

Result = Expression1 And Expression2
Result = Expression1 And Expression2(par_id3156344.4)

Parameters:
パラメータ:(hd_id3148946.5)

Result: Any numeric variable that records the result of the combination.
Result: 演算結果を格納する数値変数。(par_id3149457.6)

Expression1, Expression2: Any expressions that you want to combine.
Expression1, Expression2: 論理積の演算を行う表式。(par_id3150541.7)

Boolean expressions combined with AND only return the value True if both expressions evaluate to True:
ブール型の表式に対して AND 演算子による論理積を取る場合、2 つの表式がともに True と評価された場合のみ、結果が True となります。(par_id3156215.8)

True AND True returns True; for all other combinations the result is False.
つまり、True AND True の場合のみ結果が Trueとなり、その他の組合せはすべて False を返します。(par_id3150870.9)

The AND operator also performs a bitwise comparison of identically positioned bits in two numeric expressions.
AND 演算子はまた、2 つの数値表式を対象とするビット演算をすることもでき、この場合は両者の値を 2 進数に変換して、対応する個々のビット間を比較します。(par_id3153768.10)

Example:
例:(hd_id3153727.11)

Sub ExampleAnd
Sub ExampleAnd(par_id3149481.12)

Dim A as Variant, B as Variant, C as Variant, D as Variant
Dim A as Variant, B as Variant, C as Variant, D as Variant(par_id3152577.13)

Dim vVarOut as Variant
Dim vVarOut as Variant(par_id3152598.14)

A = 10: B = 8: C = 6: D = Null
A = 10: B = 8: C = 6: D = Null(par_id3153092.15)

vVarOut = A > B And B > C REM returns -1
vVarOut = A > B And B > C REM 戻り値は -1(par_id3146984.16)

vVarOut = B > A And B > C REM returns 0
vVarOut = B > A And B > C REM 戻り値は 0(par_id3154014.17)

vVarOut = A > B And B > D REM returns 0
vVarOut = A > B And B > D REM returns 0(par_id3149262.18)

vVarOut = (B > D And B > A) REM returns 0
vVarOut = (B > D And B > A) REM 戻り値は 0(par_id3145751.19)

vVarOut = B And A REM returns 8 due to the bitwise AND combination of both arguments
vVarOut = B And A REM 2 つの引数に対するビット単位の論理積の結果、戻り値は 8(par_id3147394.20)

End Sub
End Sub(par_id3151073.21)


< Prev / Next >